package com.payfen.client.action;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.payfen.client.jsonbean.ResultBean;
import com.payfen.util.FileTool;

@Controller
public class ClientEcouponCategoryInfAction extends Action {

	@RequestMapping(value = "/ecouponCategoryUpdate", method = RequestMethod.POST)
	public void exchangeRateUpdate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();

		String returnMsg = "";
		try {
			String merchantId = getRequestParameter(request, "merchantId");
			String userName = getRequestParameter(request, "userName");
			String userPwd = getRequestParameter(request, "userPwd");

			if (merchantId != null && !merchantId.trim().equals("") && userName != null && !userName.trim().equals("")
					&& userPwd != null && !userPwd.trim().equals("")) {
				returnMsg = "{"+
						"\"resultHead\"：{\"resultCode\"：\"0000\"，\"message\"：\"操作成功\"},"+
			 			"\"resultBody\"：{"+
							"\"body\":[{"+
								"\"id\":1,"+
								"\"categoryName\":\"光大银行金卡\","+
								"\"captcha\":\"Y\","+
								"\"startTime\":\"201205150900\","+
								"\"endTime\":\"201205312200\""+
							"},"+
							"{"+
								"\"id\":2,"+
								"\"categoryName\":\"国航金卡\","+
								"\"captcha\":\"N\","+
								"\"startTime\":\"201205150900\","+
								"\"endTime\":\"201205312200\""+
							"}]"+
						"}" +
					"}";
			} else {
				returnMsg = ResultBean.createReturnJson("0004", FileTool.getErrorCodeFromProperties("0002"),null);
			}
		} catch (Exception e) {
			e.printStackTrace();
			returnMsg = ResultBean.createReturnJson("0002", FileTool.getErrorCodeFromProperties("0002"),null);
		}
		out.write(returnMsg);
		out.flush();
		out.close();
	}
}
